/*
 * Listener.h
 *
 *  Created on: 2014. 6. 25.
 *      Author: jjaehuny
 */

#ifndef FRAMEWORK_NETWORK_LISTENER_H_
#define FRAMEWORK_NETWORK_LISTENER_H_

#include <memory>

#include <boost/asio.hpp>

#include "../Macro.h"

namespace Framework { namespace Network {

class Session;

class Listener
{
public:
	typedef std::function<void(std::shared_ptr<::Framework::Network::Session>, unsigned short)> ONACCEPTEVENT;

public:
	Listener();
	virtual ~Listener();

	void Listen(unsigned short port);

private:
	void do_accept();

private:
	SETVAR(ONACCEPTEVENT, OnAcceptEvent_);

	boost::asio::ip::tcp::socket socket_;
	boost::asio::ip::tcp::acceptor acceptor_;
};

} /*Network*/ } /*Framework*/

#endif /* FRAMEWORK_NETWORK_LISTENER_H_ */
